package com.pri.chat.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.netease.nim.uikit.net.entity.FriendsListBean;
import com.pri.chat.R;
import com.pri.chat.utils.GlideUtil;
import com.pri.chat.view.ImageViewPlus;

import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author wx5e48d604c2885118
 * @time 2020/4/24
 */
public class FriendsAdapter extends BaseQuickAdapter<FriendsListBean, BaseViewHolder> {

    private int type;

    public FriendsAdapter(int layoutResId, @Nullable List<FriendsListBean> data,int type) {
        super(layoutResId, data);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, FriendsListBean item) {
        helper.setText(R.id.age,item.getAge());
        ImageView sex = helper.getView(R.id.sex);
        View sex_age_bg = helper.getView(R.id.sex_age_bg);
        if(item.getSex().equals("男")){
            sex.setImageResource(R.mipmap.man);
            sex_age_bg.setBackgroundResource(R.drawable.btn_sex_man);
        }else{
            sex.setImageResource(R.mipmap.woman);
            sex_age_bg.setBackgroundResource(R.drawable.btn_sex_woman);
        }
        helper.setText(R.id.age,item.getAge()+"");


        TextView vip_bg = helper.getView(R.id.vip_bg);
        if("是".equals(item.getMemberLevel())){
            vip_bg.setText("VIP");
            vip_bg.setVisibility(View.VISIBLE);
        }else{
            vip_bg.setVisibility(View.GONE);
        }

        TextView vip_super_bg = helper.getView(R.id.vip_super_bg);
        if("是".equals(item.getSuperVip())){
            vip_super_bg.setText("SVIP");
            vip_super_bg.setVisibility(View.VISIBLE);
        }else{
            vip_super_bg.setVisibility(View.GONE);
        }
        if("1".equals(item.getRzStatus())){
            helper.setVisible(R.id.tv_real_verify,true);
        }else{
            helper.setVisible(R.id.tv_real_verify,false);
        }


        helper.setText(R.id.tv_friends_name,item.getNcName());
        GlideUtil.getInstance().loadHeadImg(mContext,(ImageViewPlus)helper.getView(R.id.iv_logo),item.getHeadPic());
        TextView status = helper.getView(R.id.tv_friends_status);
        if(type == 0 || type == 1){
            status.setText("取消关注");
            status.setBackgroundResource(R.drawable.btn_red_shape);
        }else if(type == 1){
            status.setText("关注Ta");
            status.setBackgroundResource(R.drawable.btn_orange_shape);
        }
    }
}
